import React from 'react';
import { inject, observer } from 'mobx-react';
import { WeaDialog, WeaNewScroll, WeaSelect, WeaBrowser, WeaDatePicker, WeaTimePicker, WeaTextarea, WeaInput, WeaUpload, WeaFormItem, WeaSearchGroup} from 'ecCom';
import { Button, Spin, Row, Col, Input, Radio, Checkbox, Modal, DatePicker } from 'antd';
import { WeaSwitch } from 'comsMobx';
// import Collapse from './collapse.js'
import isEmpty from 'lodash/isEmpty';
import mapKeys from 'lodash/mapKeys';
import {WeaLocaleProvider} from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
const ButtonGroup = Button.Group;
const RadioGroup = Radio.Group;
const CheckboxGroup = Checkbox.Group;

class RoomCreate extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      params: {
      }
    }
  }
  componentDidMount() {

  }

  componentWillReceiveProps(nextProps) {
	  if (nextProps.fields) {
		//   this.setState({ fields: nextProps.fields});
	  }
  }

  shouldComponentUpdate(nextProps, nextState) {
    if (isEmpty(nextProps.createCondition)) {
      return false;
    }
    return true
  }

  componentWillUnmount() {
    //组件卸载时一般清理一些状态
  }
  render() {
    // const {loading} = this.props
    let title = getLabel(383319,"新建会议室");
    let { visible, isEdit } = this.props;
    return (
      <WeaNewScroll height='450px'>
        <div>
          {this.getFields() }
        </div>
      </WeaNewScroll >
    )
  }

	getFields = () => {
		const {roomStore} = this.props;
		let fieldsInfo = roomStore.fields;
		let roomInfoForm = roomStore.roomInfoForm;
		const { isFormInit } = roomInfoForm;
		let group = [];
		isFormInit && fieldsInfo.map(c => {
			let items = [];
			c.items.map(fields => {
				let variable = true
                items.push({
                    com: (<WeaFormItem
                        label={`${fields.label}`}
                        labelCol={{ span: `${fields.labelcol}` }}
                        wrapperCol={{ span: `${fields.fieldcol}` }}>
                        <WeaSwitch fieldConfig={fields} form={roomInfoForm} onChange={null/*todo*/} />
                    </WeaFormItem>),
                    colSpan: 1
                })

			});
			group.push(<WeaSearchGroup col={1} needTigger={true} title={c.title} showGroup={c.defaultshow} items={items} />)
		});
		return group;
	}

}

export default RoomCreate
